package com.hyzh.latte.vehicle.dmo.entity;

import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.hyzh.latte.vehicle.dmo.PointBO;
import com.hyzh.latte.vehicle.nezha.PoleEdge;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * 摄像头
 * @author songkui
 * @since 2024/2/21 17:24
 */
@Data
@EqualsAndHashCode(of ={"id"}, callSuper = false)
@Accessors(chain = true)
@TableName("pole_point")
public class PolePointPGEntity {

    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private Long id;

    //从杆子pole_code
    @TableField("source")
    private String source;

    //到杆子pole_code
    @TableField("target")
    private String target;

    //距离【米】
    @TableField("distance")
    private Integer distance;

    //定位 list JSON
    @TableField("point_json")
    private String pointJson;

    //所属园区
    @TableField("park_code")
    private String parkCode;


    //点位编号【多个逗号隔开】
    @TableField("points")
    private String points;

    //source: ‘x’ or ‘y’
    @TableField("source_lab")
    private String sourceLab;

    //target: ‘x’ or ‘y’
    @TableField("target_lab")
    private String targetLab;

    //方向[方向: 0直行，1：左转，2，右转，-1 掉头]
    @TableField("direction")
    private Integer direction;



    public PoleEdge buildEdge(){
        PoleEdge edge = new PoleEdge();
        edge.setSourcePoleCode(source);
        edge.setTargetPoleCode(target);
        edge.setSourceLab(sourceLab);
        edge.setTargetLab(targetLab);
        edge.setDistance(distance);
        edge.setParkCode(parkCode);
        edge.setDirection(direction);
        edge.setPointList(JSONArray.parseArray(this.getPointJson(), PointBO.class));
        return edge;
    }


}
